/*
 *      animedentity.h
 *      
 *      2009 Víctor Manuel Ochoa <kanito8a@gmail.com>
 *      
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */


#ifndef CHARACTER_H
#define CHARACTER_H

#include "anim.h"
#include "log.h"
#include "texturemanager.h"
#include "filereader.h"

#include <vector>
using namespace std;

// Animations constants
const unsigned short STAND=0;
const unsigned short WALK=1;
const unsigned short JUMP=2;
const unsigned short FRAME_TIME_DEFAULT=100;
const unsigned short MAX_ANIMATION_NUM=3;
const char STRING_FILENAME[] = "file";
const char STRING_COLUMNS[] = "columns";
const char STRING_ROWS[] = "rows";
const char STRING_ANIM[] = "anim";
const char STRING_ANIMTIME[] = "animtime";
const char STRING_ANIMFRAMEPOINT[] = "framepoint";

class AnimedEntity: public Anim
{
	public:

		AnimedEntity();
		virtual ~AnimedEntity();
		bool init(TextureManager *_texture_manager,const char *_cfg_filename);
		bool init(Texture * _texture,Animation _animations[MAX_ANIMATION_NUM],unsigned short _colums_num,unsigned short _rows_num);
		bool init(float _position[3],float _rotation,float _scale[3],Texture *_texture,unsigned short _colums_num,unsigned short _rows_num);
		void update();
		void freeMemory();
		void flip();

		/*
		 * Inline set Functions
		 * */
		inline void setAnimation(unsigned short _anim){Anim::setAnim(m_animations[_anim].frames,m_animations[_anim].frame_time);}
		inline void attachEntity(Entity *_entity,unsigned short _pos){m_attached_entities[_pos]=_entity;_entity->setZ(getZ());}

	private:

		Animation m_animations[MAX_ANIMATION_NUM];
		Entity *m_attached_entities[MAX_FRAME_P0INTS];		
		Log *m_pLog;

};

#endif /* CHARACTER_H */ 
